package fractal;

import fractal.res.Resource;
import jinyilw.swing.FontTools;
import jinyilw.swing.i18n.ICSetting;
import jinyilw.swing.visuals.Icomp.ILabel;
import jinyilw.swing.visuals.Icomp.ILinkLabel;
import jinyilw.swing.visuals.Rcomp.RDialog;
import jinyilw.swing.visuals.border.RTitledBorder;
import jinyilw.swing.visuals.comp.ImageComp;
import jinyilw.swing.visuals.label.LinkLabel;

import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class AboutDialog extends RDialog
{
	private static final long serialVersionUID = -927671352131814824L;
	ILabel myInfoLabel = new ILabel();
	JPanel lxPanel = new JPanel();
	LinkLabel qqLabel = new LinkLabel("http://821073285.qzone.qq.com/");
	JPanel myInfoPanel = new JPanel();
	ILinkLabel siteLabel = new ILinkLabel(
			"http://user.qzone.qq.com/821073285/");
	ImageComp label = new ImageComp();
	ILinkLabel adviceLabel = new ILinkLabel(
			"http://user.qzone.qq.com/821073285/blog/1369554852");

	public AboutDialog(JFrame owner)
	{
		super(owner);
		setSize(500, 375);
		setResizable(false);
		setLocationRelativeTo(null);
		initGUI();
	}

	private void initGUI()
	{
		// setOpacity(0.88f);
		setOptionStyle(80, 0.92f);
		Container contentPanel = getContentPane();
		contentPanel.setLayout(null);
		addMouseListener(new ThisContentPaneMouseListener());
		setTitle(new ICSetting("aboutAuthor", "关于作者", "About author"));
		contentPanel.add(lxPanel);
		lxPanel.setOpaque(false);
		lxPanel.setBorder(
				new RTitledBorder(new ICSetting("Contact", "联系方式", "Contact"),
						FontTools.defaultFont, Color.CYAN));
		lxPanel.setLayout(null);
		lxPanel.setBounds(100, 160, 332, 115);
		lxPanel.add(qqLabel);
		qqLabel.setText("QQ：821073285");
		qqLabel.setBounds(10, 28, 185, 18);
		siteLabel.setBounds(10, 56, 300, 30);
		lxPanel.add(siteLabel);
		siteLabel.setFont(FontTools.getCustomFont(10));
		ICSetting siteISetting = new ICSetting("myHomePage", "主页：%s",
				"HomePage: %s")
				.setReplaceData("http://user.qzone.qq.com/821073285/");
		siteLabel.setText(siteISetting);
		contentPanel.add(myInfoPanel);
		myInfoPanel.setLayout(new BorderLayout());
		myInfoPanel.setBorder(new RTitledBorder(
				new ICSetting("authorInformation", "作者信息", "Information"),
				FontTools.defaultFont, Color.CYAN));
		myInfoPanel.setBounds(100, 20, 332, 115);
		myInfoPanel.add(myInfoLabel);
		myInfoLabel.setText(new ICSetting("myInfo", "姓名：王进懿\n籍贯：贵州剑河",
				"Name: Wang Jinyi\nOrigin: Jianhe Guizhou", true));
		contentPanel.add(label);
		label.setBounds(30, 80, 35, 35);
		label.setImage(Resource.getBufferedImage("icon.png"));
		contentPanel.add(adviceLabel);
		adviceLabel.setFont(FontTools.getCustomFont(14));
		adviceLabel
				.setText(new ICSetting("makeAdvice", "<<给我建议>>", "<<advice>>"));
		adviceLabel.setBounds(170, 280, 110, 30);
	}

	private class ThisContentPaneMouseListener extends MouseAdapter
	{
		@Override
		public void mouseClicked(MouseEvent e)
		{
			// WindowTools.hideWindowToBorder(AboutDialog.this, Direction.DOWN);
			dispose();
		}
	}
}
